package edu.gatech.cs4400.spring2014.A8.view;

import java.awt.CardLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * Static class that wraps the main window of the application.
 * 
 * @author Stephen
 *
 */
public abstract class ApplicationWindow {
	private static JFrame appFrame;
	private static JPanel mainPanel;
	private static CardLayout mainLayout;
	
	/**
	 * Set up and display the main application JFrame
	 */
	public static void initialize() {
		appFrame = new JFrame("[CS4400] Group 8 Phase III");
		appFrame.setMinimumSize(new Dimension(400, 600));
		appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		appFrame.setVisible(true);
		mainPanel = new JPanel();
		mainLayout = new CardLayout();
		mainPanel.setLayout(mainLayout);
		appFrame.add(mainPanel);
	}
	
	/**
	 * Provide a mapping from the String name to the panel.
	 * This mapping will be used to activate the panel.
	 * 
	 * @param panel Panel to display in the future
	 * @param name Identifying name for this panel
	 */
	public static void addView(JPanel panel, String name) {
		mainPanel.add(panel, name);
	}
	
	/**
	 * Set the window to display the specified panel.
	 * The mapping is defined by a previous call to addView()
	 * 
	 * @param name Identifying name for the panel to display
	 */
	public static void setView(String name) {
		mainLayout.show(mainPanel, name);
		mainPanel.validate();
	}
}
